<?php

//购物车

require_once('core/shop.php');

class cart {

    public function get(){
        return GS()->sessionCache_get('CARTINFO');
    }

    public function save( $data )
    {
        $cartInfo = $this->get();
        if($cartInfo) {
            foreach ($data as $d) {
                if(isset($cartInfo[$d['id']])){
                    $cartInfo[$d['id']] = '';
                }
            }
        }else{
            $cartInfo = array();
            foreach ($data as $d){
                $cartInfo[$d['id']] = $d;
            }
        }
        GS()->sessionCache_set('CARTINFO', $cartInfo);
    }


}